package com.zbkj.front.controller.user;

import com.zbkj.common.request.UserCommunityBindFrontReq;
import com.zbkj.common.response.*;
import com.zbkj.common.result.CommonResult;
import com.zbkj.common.utils.SecurityUtil;
import com.zbkj.front.service.CommunityFrontService;
import com.zbkj.service.service.UserCommunityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName CommunityController
 * @Description 用户所属小区控制器
 * @Author HZW
 * @Date 2023/3/13 9:19
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("api/front/community")
@Api(tags = "用户我的小区控制器")
public class CommunityBindController {

    @Autowired
    private UserCommunityService userCommunityService;

    @ApiOperation(value = "我的小区")
    @RequestMapping(value = "/user/community/info", method = RequestMethod.GET)
    public UserCommunityFrontInfoResponse getUserCommunityInfo() {
        return userCommunityService.getUserCommunityInfo();
    }

    @ApiOperation(value = "绑定小区") //配合swagger使用
    @RequestMapping(value = "/user/bind", method = RequestMethod.POST)
    public CommonResult bindCommunity(@RequestBody @Validated UserCommunityBindFrontReq bindProductRequest) {
        return CommonResult.success(userCommunityService.bindCommunity(bindProductRequest));
    }

    @ApiOperation(value = "解绑小区") //配合swagger使用
    @RequestMapping(value = "/user/unbind", method = RequestMethod.POST)
    public CommonResult unbindCommunity() {
        return CommonResult.success(userCommunityService.unbindCommunity());
    }

}
